package com.example.spirngbootdemo;

import lombok.extern.slf4j.Slf4j;
import org.slf4j.MDC;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableAsync;

import java.util.UUID;

@SpringBootApplication
@EnableAsync
@Slf4j
public class SpirngBootDemoApplication implements ApplicationRunner {

    public static void main(String[] args) {
        SpringApplication.run(SpirngBootDemoApplication.class, args);
    }

    @Override
    public void run(ApplicationArguments args) throws Exception {
        MDC.put("requestId",  UUID.randomUUID().toString());
        log.info("run application");
    }

    // @Bean
    // public AsyncTaskExecutor taskExecutor() {
    //     ThreadPoolTaskExecutor executor = MdcThreadPoolTaskExecutor.newWithInheritedMdc(8, 32, 1, TimeUnit.MINUTES, 1000);
    //     executor.setThreadNamePrefix("Anno-Executor");
    //     executor.setMaxPoolSize(10);
    //
    //     return executor;
    // }
}
